// abcd.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

int main(int argc, char* argv[])
{
	int y1,m1,d1,y2,m2,d2,days;
	scanf("%d %d %d",&y1,&m1,&d1);
	switch(m1)
	{
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			{
				days=31;
				break;
			}
		case 4:
		case 6:
		case 9:
		case 11:
			{
				days=30;
				break;
			}
	}


	if(y1%100==0)
	{
		if(y1%400==0)
		{
			if(m1==2)
				days=29;
		}
		else 
		{
			if(m1==2)
				days=28;
		}
	}
	else
	{
		if(y1%4==0)
		{
			if(m1==2)
				days=29;
		}
		else
		{
			if(m1==2)
				days=28;
		}
	}

	d2=d1+1;
	if(d2>days)
	{	
		d2=1;
		m2=m1+1;
	}
	else 
		m2=m1;

	if(m2>12)
	{ 
		m2=1;
		y2=y1+1;
	}
	else 
		y2=y1;
	printf("%d %d %d",y2,m2,d2);
	return 0;
}

